package io.kiki.sba.registry.server.metadata;

import io.kiki.sba.registry.store.api.elector.Leader;


public interface MetadataLeaderService {

    /**
     * Am i elector boolean.
     */
    boolean amILeader();

    /**
     * Gets get elector.
     */
    String getLeader();

    /**
     * Gets get elector epoch.
     */
    long getLeaderEpoch();

    /**
     * get leader info
     */
    Leader getLeaderInfo();

    /**
     * Gets get meta server elector state.
     */
    boolean isWarmuped();

    /**
     * Am i stable as elector boolean.
     */
    default boolean amIStableAsLeader() {
        return amILeader() && isWarmuped();
    }

    void registerListener(LeaderElectorListener leaderElectorListener);

    interface LeaderElectorListener {

        void becomeLeader();

        void loseLeader();
    }
}
